from django.db import models
from hosting.services.models import UsedService
from hosting.accounts.models import User

class DatabaseHost(models.Model):
    name = models.CharField(max_length=100)
    comment = models.CharField(max_length=255)

    def __unicode__(self):
        return self.name

class Database(models.Model):
    host = models.ForeignKey(DatabaseHost)
    name = models.CharField(max_length=50)
    used_service = models.ForeignKey(UsedService)
    users = models.ManyToManyField(User)

    def __unicode__(self):
        return self.name

    class Meta:
        ordering = ["name"]
    
class UsersDatabase(models.Model):
    database = models.ForeignKey(Database)
    user = models.ForeignKey(User)
